#pragma once
#include<iostream>
#include<string>
using namespace std;

const int defaultvalue = 0; 
string opers = "+-*/%";
enum //计算的状态码
{
    ok = 0,
    div_zero,
    mod_zero,
    unknow
};

class Task //任务
{
public:
    Task()
    {}
    Task(int x, int y, char op)
        : _data1(x), _data2(y), _op(op), _result(defaultvalue), _code(ok)
    {}

    void Run()
    {
        switch (_op)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '/':
        {
            if (_data2 == 0)
                _data2 = div_zero;
            else
                _result = _data1 / _data2;
        }
        break;
        case '%':
        {
            if (_data2 == 0)
                _code = mod_zero;
            else
                _result = _data1 % _data2;
        }

        break;
        default:
            _code = unknow;
            break;
        }
    }
    void operator()() //重载括号运算符
    {
        Run();
    }

    string PrintTask()
    {
        string s;
        s = to_string(_data1) + _op + to_string(_data2) + " = ?";
        return s;
    }

    string PrintResult()
    {
        string s;
        s = to_string(_data1) + _op + to_string(_data2) + " = " + to_string(_result) + " code: " + to_string(_code);
        return s;
    }

    ~Task()
    {}
private:
    int _data1;
    int _data2;
    int _code;  // 结果码，0: 可信 !0: 不可信
    int _result;
    char _op; //+，-，*，/，%
};